import numpy as np
import pandas as pd
arr = np.random.randint(1,100,5)
print('一维原始数据 :\n',arr)
print('等差分段离散化数据: \n',pd.cut(arr,bins=5))
print('自定义分段离散化数据: \n',pd.cut(arr,bins=[0,20,40,60,80,100]))
print('自定义分段离散化数据，并设置分段标签: \n',pd.cut(arr,bins=[0,20,40,60,80,100],labels=['0+','20+','40+','60+','80+']))